﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Rbac.Read.APi.Application.Command.Jobs;
using T_Rbac.Read.APi.Application.Command.Quanxian;
using T_Rbac_Demain;

namespace T_Rbac.Read.APi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        private readonly IMediator mediator;

        public JobController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取下来列表
        /// </summary>
        /// <param name="jobListCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Job>> GetJoblist([FromQuery] JobListCommand jobListCommand)
        {
            return await mediator.Send(jobListCommand);
        }
        /// <summary>
        /// 分页,查询
        /// </summary>
        /// <param name="jobSearchByPageResult"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Job>> GetJobPageResult([FromQuery] JobSearchByPageResult jobSearchByPageResult)
        {
            return await mediator.Send(jobSearchByPageResult);
        }
        /// <summary>
        /// 角色级联
        /// </summary>
        /// <param name="jobTreeListCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PublicTree<Job>>> GetJobPublicTrees([FromQuery] JobTreeListCommand jobTreeListCommand)
        {
            return await mediator.Send(jobTreeListCommand);
        }
        /// <summary>
        /// 权限反填
        /// </summary>
        /// <param name="quanxianFantianByIdCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int[]> FanQuanxianid([FromQuery]QuanxianFantianByIdCommand quanxianFantianByIdCommand)
        {
            return await mediator.Send(quanxianFantianByIdCommand);
        }
        /// <summary>
        /// 获取权限的菜单
        /// </summary>
        /// <param name="quanxianFantianByidIncludeMpidCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PublicTree<Menues>>> GetJobMenues([FromQuery]QuanxianFantianByidIncludeMpidCommand quanxianFantianByidIncludeMpidCommand)
        {
            return await mediator.Send(quanxianFantianByidIncludeMpidCommand);
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="jobSearchByIdCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Job> FantianJob([FromQuery]JobSearchByIdCommand jobSearchByIdCommand)
        {
            return await mediator.Send(jobSearchByIdCommand);
        }
    }
}
